package config.security;

import org.springframework.security.authentication.ReactiveAuthenticationManager;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Mono;
@Component
public class MyAuthenticationManager implements ReactiveAuthenticationManager {

    @Override
    public Mono<Authentication> authenticate(Authentication authentication) {
//        Object principal = authentication.getPrincipal();
//        Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
//        Object credentials = authentication.getCredentials();
//        System.out.println();
//        String token = (String) authentication.getPrincipal();
//        Claims claimFromToken = JwtTokenUtil.getClaimFromToken(token);
//        if (claimFromToken != null) {
//            String username = (String) claimFromToken.get(JwtTokenUtil.CLAIM_KEY_USERNAME);
//            Collection<GrantedAuthority> o1 = (Collection<GrantedAuthority>) claimFromToken.get(JwtTokenUtil.CLAIM_KEY_ROLES);
//            return Mono.just(new UsernamePasswordAuthenticationToken(username, username, o1));
//
//        }
        return Mono.empty();
    }
}
